/**
 * 
 */
package py.edu.ucom.cadira.net.serializables;

import org.jdom.Document;
import org.jdom.Element;
import py.edu.ucom.cadira.net.XMLSerializable;

/**
 * @author largonet
 * 
 */
public class SetBoardResponse implements XMLSerializable {
    private static final String NODE_SET_BOARD = "setBoard";
    private boolean status;

    /**
     * Constructor de la clase
     * 
     */
    public SetBoardResponse() {
    }
    /**
     * @return Returns the status.
     */
    public boolean isStatus() {
        return status;
    }
    /**
     * @param status
     *            The status to set.
     */
    public void setStatus(boolean status) {
        this.status = status;
    }
    public void fromXML(Document xml) {
        // pido el root del XML (CADIRA)
        Element root = xml.getRootElement();
        Element setBoard = root.getChild(NODE_SET_BOARD);
        Element statusNode = setBoard.getChild("status");
        this.status = Boolean.valueOf(statusNode.getValue());
    }
    public void toXML(Element root) {
        // arma la cabecera de la tabla
        Element joinTableNode = new Element(NODE_SET_BOARD);
        Element statusNode = new Element("status");
        statusNode.addContent(String.valueOf(this.status));
        joinTableNode.addContent(statusNode);
        root.addContent(joinTableNode);
    }
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof SetBoardResponse)) {
            return false;
        }
        SetBoardResponse otherObj = (SetBoardResponse) obj;
        if (otherObj.isStatus() == isStatus()) {
            return true;
        }
        return false;
    }
}
